package com.mvd.app.ac2019;

import android.os.Bundle;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;

import com.mvd.app.R;
import com.mvd.app.activity.BaseActivity;
import com.mvd.app.commons.SharedPreferencesUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/***
 *
 * 高级设置
 *
 * **/
public class AdvanceSettingActivity extends BaseActivity implements CompoundButton.OnCheckedChangeListener {

    @BindView(R.id.title_btn_left)
    ImageButton titleBtnLeft;
    @BindView(R.id.title_btn_left_txt)
    Button titleBtnLeftTxt;
    @BindView(R.id.title_txt)
    TextView titleTxt;
    @BindView(R.id.iv_headtip)
    ImageView ivHeadtip;
    @BindView(R.id.title_btn_right_txt)
    Button titleBtnRightTxt;
    @BindView(R.id.title_btn_right)
    ImageButton titleBtnRight;
    @BindView(R.id.ac_advance_set_chongxin_xiaxian)
    Switch acAdvanceSetChongxinXiaxian;
    @BindView(R.id.ac_advance_set_buchuan_zhaopian)
    Switch acAdvanceSetBuchuanZhaopian;
    @BindView(R.id.ac_advance_set_switch)
    Switch acAdvanceSetSwitch;
    @BindView(R.id.ac_advance_set_switch_net)
    Switch acAdvanceSetSwitchNet;

    private AdvanceSettingActivity instances = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advance_setting);
        ButterKnife.bind(this);
        instances = this;
        setTopTitle("高级设置");
        setBackBtn();
        acAdvanceSetSwitch.setOnCheckedChangeListener(this);
        acAdvanceSetChongxinXiaxian.setOnCheckedChangeListener(this);
        acAdvanceSetBuchuanZhaopian.setOnCheckedChangeListener(this);
        acAdvanceSetSwitchNet.setOnCheckedChangeListener(this);


        if (SharedPreferencesUtils.getWenZhouNet(instances)) {
            //Todo温州联网调试开始  默认：关
            acAdvanceSetSwitchNet.setChecked(true);
        } else {
            //Todo
            acAdvanceSetSwitchNet.setChecked(false);
        }


        if (SharedPreferencesUtils.getPhotoAlbumStatement(instances)) {
            //Todo
            acAdvanceSetSwitch.setChecked(true);
        } else {
            //Todo
            acAdvanceSetSwitch.setChecked(false);
        }
        //重新下线与补传照片的开关显示与隐藏
        if (SharedPreferencesUtils.getChongXinXiaXianStatement(instances)) {
            acAdvanceSetChongxinXiaxian.setChecked(true);
        } else {
            acAdvanceSetChongxinXiaxian.setChecked(false);
        }

        if (SharedPreferencesUtils.getBuChuanZhaoPianStatement(instances)) {
            acAdvanceSetBuchuanZhaopian.setChecked(true);
        } else {
            acAdvanceSetBuchuanZhaopian.setChecked(false);
        }


    }

//    @OnClick({R.id.ac_advance_set_chongxin_xiaxian, R.id.ac_advance_set_buchuan_zhaopian})
//    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.ac_advance_set_chongxin_xiaxian:
//                //重新下线
//                Intent i = new Intent(instances, DownLineCarsListActivity.class);
//                startActivity(i);
//                break;
//            case R.id.ac_advance_set_buchuan_zhaopian:
//                //补传照片
//                Intent intent = new Intent(instances, RecheckPhotoListActivity.class);
//                startActivity(intent);
//                break;
//        }
//    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()) {
            case R.id.ac_advance_set_chongxin_xiaxian:
                //重新下线开关
                SharedPreferencesUtils.setChongXinXiaXianStatement(instances, isChecked);
                break;
            case R.id.ac_advance_set_buchuan_zhaopian:
                //补传照片开关
                SharedPreferencesUtils.setBuChuanZhaoPianStatement(instances, isChecked);
                break;
            case R.id.ac_advance_set_switch:
                //外检拍照相册开关
                SharedPreferencesUtils.setPhotoAlbumStatement(instances, isChecked);
                break;
            case R.id.ac_advance_set_switch_net:
                //温州联网调试开始  默认：关
                SharedPreferencesUtils.setWenZhouNet(instances, isChecked);
                break;
        }
    }
}
